package myJs.components

/**
 * Created by yz on 17/12/2020
 */

import japgolly.scalajs.react._
import japgolly.scalajs.react.extra._
import japgolly.scalajs.react.vdom.html_<^._

object TestComponent {

  final case class Props(state: StateSnapshot[State]) {
    @inline def render: VdomElement = Component(this)
  }

  //implicit val reusabilityProps: Reusability[Props] =
  //  Reusability.derive

  final case class State()

  object State {
    def init: State =
      State()

    //implicit val reusability: Reusability[State] =
    //  Reusability.derive
  }

  final class Backend($: BackendScope[Props, Unit]) {
    def render(p: Props): VdomNode = {
      val s = p.state.value
      <.div
    }
  }

  val Component = ScalaComponent.builder[Props]("TestComponent")
    .renderBackend[Backend]
    //.configure(Reusability.shouldComponentUpdate)
    .build
}